const { request } = require("/utils");

const app = getApp();
Page({
    data: {
        userInfo: null
    },
    onLoad() {
        my.setCanPullDown({ canPullDown: false });
        this.getUserInfo();
    },
    login() {
        app.login(userInfo => this.setData({ userInfo }));
    },
    getAuthCode() {
        my.getAuthCode({
            scopes: ['auth_user'],
            success(res) {
                console.log(res);
            }
        })
    },
    async getUserInfo() {
        app.getUserInfo(userInfo => this.setData({ userInfo }));
    },
    toModify() {
        my.navigateTo({ url: '/pages/modifyUserInfo/modifyUserInfo' });
    },
    previewAvatar() {
        my.previewImage({
            enableSavePhoto: true,
            urls: [this.data.userInfo.avatar]
        })
    }
});